package com.gzdh.dishrecognition.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gzdh.dishrecognition.R;

public class KlDialog extends Dialog {
    private Context mContext;
    private Window window = null;


    public KlDialog(@NonNull Context context) {
        super(context, R.style.CustomDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this.getContext();
        View view = getView();
        setContentView(view);

        //点击dialog以外的空白处是否隐藏
//        setCanceledOnTouchOutside(false);
        //初始化界面控件
        initView();
        //初始化界面数据
        initData();
        //初始化界面控件的事件
        initEvent();
        //设置窗口显示
        windowDeploy();
    }

    private void initView() {

    }

    private void initData() {

    }


    private void initEvent() {

    }

    private void windowDeploy() {
        window = getWindow();
        window.setGravity(Gravity.CENTER); //设置窗口显示位置
//        window.setWindowAnimations(R.style.dialogWindowAnim); //设置窗口弹出动画
    }

    private View getView() {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

        LinearLayout mainLayout = new LinearLayout(mContext);
        mainLayout.setLayoutParams(layoutParams);
        mainLayout.setBackgroundColor(Color.WHITE);
        mainLayout.setOrientation(LinearLayout.VERTICAL);

        //初始化标题
        TextView titleTv = new TextView(mContext);
        titleTv.setText("新增卡类");
        titleTv.setLayoutParams(layoutParams);
        titleTv.setTextColor(Color.BLACK);
        titleTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        mainLayout.addView(titleTv);
        return mainLayout;
    }

}
